//
//  ServiceConfig.m
//  jinwan
//
//  Created by 王尧 on 2017/5/26.
//  Copyright © 2017年 wy. All rights reserved.
//

#import "ServiceConfig.h"
NSString *const KGKNet_Env = @"net_env";
NSString *const kNet_Custom_Data = @"net_custom_data";
@implementation ServiceConfig

+ (instancetype)shareInstance
{
    static ServiceConfig *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[ServiceConfig alloc] init];
    });
    return instance;
}

- (void)confingureAppEnv:(Net_ENV)env
{
    self.env = env;
    
#if 1
    [[NSUserDefaults standardUserDefaults] setObject:@(env) forKey:KGKNet_Env];
    [[NSUserDefaults standardUserDefaults] synchronize];
#endif
}

- (void)debugModelConfingure
{
    NSNumber *env = [[NSUserDefaults standardUserDefaults] objectForKey:KGKNet_Env];
    if (env) {
        [self confingureAppEnv:env.integerValue];
        if (env.integerValue == Net_ENV_CUSTOM) {
            NSDictionary *data = [[NSUserDefaults standardUserDefaults] objectForKey:kNet_Custom_Data];
            [ServiceConfig shareInstance].customHost = data;
        }
    }
    
}

- (void)writeCustomUrlDic:(NSDictionary *)dic
{
    [[NSUserDefaults standardUserDefaults] setObject:dic forKey:kNet_Custom_Data];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

@end
